package com.heng.syncUp;

import org.openjdk.jol.info.ClassLayout;

import java.util.concurrent.TimeUnit;

public class SynchronizedDemo3 {
    public static void main(String[] args) {
        //先睡5秒，保证开启偏向锁
        try {TimeUnit.SECONDS.sleep(5);}catch (InterruptedException e) {e.printStackTrace();}

        Object o = new Object();
        synchronized (o) {
            o.hashCode();
            System.out.println("偏向锁过程中遇到一致性哈希计算请求，立马撤销偏向模式，膨胀为重量级锁");
            System.out.println(ClassLayout.parseInstance(o).toPrintable());
        }
    }
}
